import Vuex from 'vuex'
import Vue from 'vue'

Vue.use(Vuex)

var constStore = {
    state: { 
        todos: [
            {
                id: 1,
                name: '日出',
                done: true
            },
            {
                id: 2,
                name: '日落',
                done: false
            },
            {
                id: 3,
                name: '云去',
                done: true
            },
            {
                id: 4,
                name: '云归',
                done: false
            }
        ],
        count: 0
    },
    getters: {
        doneTodos: status => {
            return status.todos.filter(intex => intex.done)
        },
        doneTodofalse: status => {
            return status.todos.filter(intex => !intex.done)
        }
    },
    mutations: {
        increment(state) {
            state.count++
        },
        incrementcount(state, num) {
            state.count += num.amount
        }
    }
}

const store = new Vuex.Store(constStore)

store.commit({
   type: 'incrementcount', 
   amount: 10
})


export default store